package com.dgut.controller;


import com.dgut.result.Result;
import com.dgut.service.SalesOrdersService;
import com.dgut.vo.OrderVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "订单管理接口")
@RequestMapping("/order")
@Slf4j
public class OrderController {
    @Autowired
    private SalesOrdersService salesOrdersService;

    /**
     * 根据合同id查询相关订单
     *
     * @param contractId
     * @return
     */
    @GetMapping("/contract/{contractId}")
    @ApiOperation("根据合同id查询相关订单")
    public Result getOrdersByContractId(@PathVariable Long contractId) {
        log.info("根据合同id查询相关订单，参数contractId:{}", contractId);
        List<OrderVO> list = salesOrdersService.getOrdersByContractId(contractId);
        log.info("根据合同id查询相关订单，结果list:{}", list);
        return Result.success(list);
    }

}
